<template>
  <div id="redactDialog">
    <!--<el-button type="text" @click="dialogVisible = true">点击打开 Dialog</el-button>-->
    <el-dialog
      title="查看"
      :visible.sync="detaildialogShow"
      class="box"
      :before-close="handleClose"
    >
      <el-form :model="form">
        <el-form-item class="borderNone" label="站点编号：" :label-width="formLabelWidth">
          <el-input v-model="form.pid" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item class="borderNone" label="站点名称：" :label-width="formLabelWidth">
          <el-input v-model="form.name" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item class="borderNone" label="心跳频率(s)：" :label-width="formLabelWidth">
          <el-input v-model="form.refresh_interval" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item class="borderNone" label="超时时间(s)：" :label-width="formLabelWidth">
          <el-input v-model="form.timeout" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item class="borderNone" label="连接状态：" :label-width="formLabelWidth">
          <el-input v-model="form.conn_status" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item class="borderNone" label="接入时间：" :label-width="formLabelWidth">
          <el-input v-model="form.conn_time" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item class="borderNone" label="到期时间：" :label-width="formLabelWidth">
          <el-input v-model="form.expire_time" auto-complete="off"></el-input>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
  import axios from 'axios'

  export default {
    props: ['userIndex', 'userRow'],
    data() {
      return {
        form: {
          pid: '',
          name: '',
          timeout: '',
          refresh_interval: '',
          conn_status: '',
          conn_time: '',
          expire_time: ''
        },
        formLabelWidth: '106px',
        dialogBack: false,
        submitdata: {
          access_token: window.localStorage.getItem('access_token'),
          type: 'heartbeat_get_bypid',
          pid: this.userRow[this.userIndex].pid
        }
      }
    },
    created() {
      this.detaildialogShow = true
    },
    mounted() {
      this.formParent()
      this.queryData()
    },
    methods: {
      // 子组件传值
      handleClose() {
        const dialogShow = this.dialogBack // 所需要传的值
        this.$emit('giveFalse', dialogShow) // 传值的参数
      },
      // 接受父组件的值
      formParent() {
        console.log(this.userIndex)
        console.log(this.userRow)
      },
      // 以下为获取数据方法
      // 获取列表信息
      queryData() {
        /* 有登录后可调整为以下代码**/
        /*
        updateRecord(this.submitdata).then(res => {
          console.log(11111111111111)
          console.log(res)
          this.$router.push({
            // path: 'usermanage'
          })
        }).catch(() => {
          console.log('失败!')
          return
        })*/
        // 配置更新总览
        axios.post('/heartbeat', this.submitdata, {
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((res) => {
          this.form = res.data.data
          console.log(this.form)
        })
          .catch(function(error) {
            console.log(error)
          })
      }
    }
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  /*****************第一层弹窗*****************/
  /deep/ .box > .el-dialog{
    width: 540px !important;
    min-height: 360px;
    margin-top: 23vh !important;
    border-radius: 4px;
  }
  /*****************第一层弹窗头部*****************/
  /deep/ .box > .el-dialog > .el-dialog__header{
    width: 540px;
    height: 39px;
    line-height: 43px;
    padding: 0;
    text-indent: 20px;
    font-weight: bolder;
    border-radius: 4px 4px 0 0;
    background-color: #e3e6ee;
  }
  /deep/ .box > .el-dialog > .el-dialog__header > .el-dialog__headerbtn{
    top: 12px;
  }
  /deep/ .box > .el-dialog > .el-dialog__header > .el-dialog__headerbtn > i{
    font-size: 18px;
    font-weight: bolder;
  }
  /*****************第一层弹窗内容*****************/
  /deep/ .box > .el-dialog > .el-dialog__body{
    padding: 0 0 10px 10px ;
    margin-top: 20px;
  }
  /deep/ .box > .el-dialog > .el-dialog__body > .el-form > .el-form-item{
    margin-bottom: 10px;
  }
  /deep/ .box > .el-dialog > .el-dialog__body > .el-form > .el-form-item > .el-form-item__content{
    margin-left: 106px !important;
  }
  /deep/ .box > .el-dialog > .el-dialog__body > .el-form > .el-form-item > .el-form-item__label{
    color: #69727E;
    padding: 0 5px 0 0;
    font-weight: normal;
  }
  /deep/ .box > .el-dialog > .el-dialog__body > .el-form > .el-form-item > .el-form-item__content > .el-input > .el-input__inner{
    width: 410px;
    height: 30px;
    padding: 0 5px;
  }
  /deep/ .box > .el-dialog > .el-dialog__body > .el-form > .borderNone > .el-form-item__content > .el-input > .el-input__inner{
    border: none;
  }
  /*****************第一层弹窗底部*****************/
  /deep/ .box > .el-dialog > .el-dialog__footer{
    border-top: 1px solid #e3e6ee;
  }
  /*****************底部按钮*****************/
  /deep/ .dialog-footer{
    padding-top: 8px;
  }
  /deep/ .dialog-footer > .el-button{
    width: 80px;
    height: 30px;
    padding: 0;
  }
</style>
